package com.tianqu.tms.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tianqu.tms.core.base.TmsEntity;
import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dao.TransferStatusCountDao;
import com.tianqu.tms.dto.TransferStatusCountDto;

public class TransferStatusCount extends TmsEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7333287848624704144L;

	private int id;
	private String status;
	private int count;
	private String countDay;
	private int count1;
	private int count2;
	private int count3;
	private int count4;
	private int count5;
	private int count6;
	
	public TransferStatusCount getTransferStatusCountInfo(String countDay) throws TmsDaoException
	{
		TransferStatusCountDao uDao = (TransferStatusCountDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_STATUS_COUNT);
		TransferStatusCountDto dto = uDao.getTransferStatusCountInfo(countDay);
		TransferStatusCount entity = null;
		if(dto!=null)
		{
			entity = new TransferStatusCount();
			entity.setCountDay(dto.getCountDay());
		}
		return entity;
	}
	public List getTransferStatusCountList() throws TmsDaoException
	{
		TransferStatusCountDao uDao = (TransferStatusCountDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_STATUS_COUNT);
		List<TransferStatusCountDto> dtoList = uDao.getTransferStatusCountList();
		List list = null;
		if(dtoList!=null)
		{
			list = new ArrayList();
			if(dtoList.size() > 1)
			{
				int size = dtoList.size();
				if(dtoList.size()>30)
				{
					size=31;
				}
				for(int i=1;i<size;i++)
				{
					TransferStatusCountDto dto = (TransferStatusCountDto)dtoList.get(i);
					Map map = new HashMap();
					map.put("itemValue",dto.getCountDay());
					map.put("itemCode", dto.getCountDay());
					list.add(map);
				}
			}
		}
		return list;
	}
	public TransferStatusCount getTransferStatusCountByWeekId(String countDay) throws TmsDaoException
	{
		TransferStatusCountDao uDao = (TransferStatusCountDao) TmsDao.getInstance(TmsDao.TMS_TRANSFER_STATUS_COUNT);
		List<TransferStatusCountDto> dtoList = uDao.getTransferStatusCountByWeekId(countDay);
		TransferStatusCount entity = null;
		if(dtoList!=null)
		{
			int count1=0;
			int count2=0;
			int count3=0;
			int count4=0;
			int count5=0;
			int count6=0;
			entity = new TransferStatusCount();
			for(int i=0;i<dtoList.size();i++)
			{
				TransferStatusCountDto dto = (TransferStatusCountDto)dtoList.get(i);
				
				if(dto.getStatus()==1)
				{
					count1 = count1 + dto.getCount();
				}
				if(dto.getStatus()==2)
				{
					count2 = count2 + dto.getCount();
				}
				if(dto.getStatus()==3)
				{
					count3 = count3 + dto.getCount();
				}
				if(dto.getStatus()==4)
				{
					count4 = count4 + dto.getCount();
				}
				if(dto.getStatus()==5)
				{
					count5 = count5 + dto.getCount();
				}
				if(dto.getStatus()==6)
				{
					count6 = count6 + dto.getCount();
				}
			}
			entity.setCount1(count1);
			entity.setCount2(count2);
			entity.setCount3(count3);
			entity.setCount4(count4);
			entity.setCount5(count5);
			entity.setCount6(count6);
		}
		return entity;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public String getCountDay() {
		return countDay;
	}

	public void setCountDay(String countDay) {
		this.countDay = countDay;
	}

	public int getCount1() {
		return count1;
	}
	public void setCount1(int count1) {
		this.count1 = count1;
	}
	public int getCount2() {
		return count2;
	}
	public void setCount2(int count2) {
		this.count2 = count2;
	}
	public int getCount3() {
		return count3;
	}
	public void setCount3(int count3) {
		this.count3 = count3;
	}
	public int getCount4() {
		return count4;
	}
	public void setCount4(int count4) {
		this.count4 = count4;
	}
	public int getCount5() {
		return count5;
	}
	public void setCount5(int count5) {
		this.count5 = count5;
	}
	public int getCount6() {
		return count6;
	}
	public void setCount6(int count6) {
		this.count6 = count6;
	}
	@Override
	public void save() throws TmsDaoException, TmsException {
		// TODO Auto-generated method stub

	}

}
